import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { Cache } from "../../cache/Cache";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { TaskTargetInfo } from "../../model/TaskTargetInfo";
import { TargetNPCSPrite } from "../common/TargetNPCSPrite";
import { ENpcEffect } from "../../../../Message/Public/ENpcEffect";
import { GameController } from "../../mvc/GameController";
import { GLabel } from "../../../../com/mui/controls/GLabel";
//class GuildTaskWindow
    
    export  class GuildTaskWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public init(): void
        {
            var loc2=null;
            var loc3=null;
            this.setSize(340, 250);
            this.titleHeight = 28;
            this.title = Language.getString(57028);
            ObjCreate.createBg(20, 42, 300, 195, this);
            this._tipText = ObjCreate.createTextField("", 25, 45, 280, 200, this);
            this._tipText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipText.htmlText = Language.getString(57029);
            var loc1=Cache.instance.daily.guildTaskInfo;
            this._taskTxt = ObjCreate.createTextField(Language.getString(57030), 25, 115, 280, 200, this, GlobalStyle.textFormat2);
            this._taskNumTxt = ObjCreate.createTextField("（" + loc1.num + "/" + loc1.totalNum + "）", 85, 115, 220, 20, this);
            this._npcInfoArray = Cache.instance.scene.getGuildTaskNPC();
            var loc4=0;
            while (loc4 < this._npcInfoArray.length) 
            {
                loc3 = this._npcInfoArray[loc4] as TaskTargetInfo;
                loc2 = new TargetNPCSPrite();
                loc2.data = loc3;
                loc2.x = 25;
                loc2.y = 135 + loc4 * 20;
                this.addChild(loc2);
                ++loc4;
            }
            var loc5=Cache.instance.daily.runBussinessInfo;
            this._businessTxt = ObjCreate.createTextField(Language.getString(57030), 25, 185, 220, 20, this, GlobalStyle.textFormat2);
            this._businessNumTxt = ObjCreate.createTextField("（" + loc5.num + "/" + loc5.totalNum + "）", 85, 185, 220, 20, this);
            var loc6=Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcGuildGetRunBusiness);
            this._businessNpc = new TargetNPCSPrite();
            this._businessNpc.data = loc6;
            this._businessNpc.x = 25;
            this._businessNpc.y = 205;
            this.addChild(this._businessNpc);
            return;
        }

        public updateTaskNum(): void
        {
            var loc1=Cache.instance.daily.guildTaskInfo;
            if (this._taskNumTxt && loc1) 
            {
                this._taskNumTxt.text = "（" + loc1.num + "/" + loc1.totalNum + "）";
            }
            var loc2=Cache.instance.daily.runBussinessInfo;
            if (this._businessNumTxt && loc2) 
            {
                this._businessNumTxt.text = "（" + loc2.num + "/" + loc2.totalNum + "）";
            }
            return;
        }

        /* internal  */onNpcItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            GameController.guild.guildModule.hide();
            return;
        }

        /* internal */ /* var */_titleLabel: GLabel;

        /* internal */ /* var */_tipText: Object /* flash.text.TextField */;

        /* internal */ /* var */_taskTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_taskNumTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_businessTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_businessNumTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_businessNpc: TargetNPCSPrite;

        /* internal */ /* var */_npcInfoArray: Array<any>;
    }
